import axios from "../utils/axios"
// 页面渲染（查询）
const dataAll = (page: number, limit: number, name: string, cityId: number, provinceId: number, organId: number) => {
    return axios({
        url: '/package/findAll',
        method: 'post',
        data: {
            page: page,
            limit: limit,
            name: name,
            cityId: cityId,
            provinceId: provinceId,
            organId: organId
        }
    })
}
// 套餐组成渲染
const PackageDatas = (id: Number) => {
    return axios({
        url: '/package/findPackageItemsByPackageId?packageId=' + id + ''
    })
}
// 添加
const addData = (_data: any) => {
    return axios({
        url: '/package/add',
        method: 'post',
        data: _data
    })
}
// 套餐里面添加体检项
const addExamination1 = (examintionId: object, packageId: Number) => {
    return axios({
        url: '/package/addItemToPackage',
        method: 'post',
        data: {
            itemIds: examintionId,
            packageId: packageId
        }
    })
}
// 加项包添加
const Additions = (itemIds: object, packageId: number) => {
    return axios({
        url: '/additionalPackage/insert',
        method: 'post',
        data: {
            itemIds: itemIds,
            packageId: packageId
        }
    })

}
// 加项包页面渲染
const additionspage = (id: Number) => {
    return axios({
        url: '/additionalPackage/list?packageId=' + id + ''
    })
}
// 编辑查询数据
const edit1Data = (id: Number) => {
    return axios({
        url: '/package/findPackageById?id=' + id + '',
    })
}
//编辑
const edit2Data = (_data: { id: null; name: string; organName: string; cityName: string; provinceName: string; originalPrice: null; currentPrice: null; packageDescription: string; packageIntroduction: string; packageRole: string; packageTag: number; status: number; subOrganIds: number[]; effectiveTime: string }) => {
    return axios({
        url: '/package/update',
        method: 'post',
        data: _data
    })
}
// 删除
const delData = (id: Number) => {
    return axios({
        url: '/package/deleteById?id=' + id + ''
    })
}
const delexam = (itemIds: object, packageId: Number) => {
    return axios({
        url: '/package/removePackageItemsFromPackage',
        method: 'post',
        data: {
            itemIds: itemIds,
            packageId: packageId
        }
    })
}
// 批量删除
const delDatas = (ids: object) => {
    return axios({
        url: '/package/deleteByIds',
        method: 'post',
        data: {
            ids: ids
        }
    })
}
const deladditions = (itemIds: object, packageId: Number) => {
    return axios({
        url: '/additionalPackage/delete',
        method: 'post',
        data: {
            itemIds: itemIds,
            packageId: packageId
        }
    })
}
// 图片
const image = (_data: FormData) => {
    return axios({
        url: '/upload/image',
        method: 'post',
        data: _data,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}
const image1 = (images: object, packageId: number) => {
    return axios({
        url: '/package/insertPackageBanner',
        method: 'post',
        data: {
            images: images,
            packageId: packageId
        }
    })
}
const images2 = (packageId: number) => {
    return axios({
        url: '/package/findAllBanner?packageId=' + packageId + ''
    })
}
const deleteImage = (id: number) => {
    return axios({
        url: '/package/deleteBannerById?id=' + id + ''
    })
}
export {
    addData,
    addExamination1,
    dataAll,
    edit1Data,
    edit2Data,
    delData,
    delDatas,
    PackageDatas,
    delexam,
    image,
    image1,
    images2,
    deleteImage,
    Additions,
    additionspage,
    deladditions
}